package com.cy.pj.sys.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalTime;
@Slf4j
public class TimeAccessInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        LocalTime time = LocalTime.now();
         int  hour = time.getHour();
         if (hour>6&&hour<24){
             return true;
         }
            log.info("你被拦截了");
         return false;
    }
}
